<?php 

include_once '../Model/Game/OPGame.php';
include_once '../Model/Player/OPRebel.php';

session_start();

if (!$_SESSION['game']) {       
        $game = OPGame::newGame();

        $_SESSION['game'] = $game;

        $player = OPRebel::newWithEmei('1');
        
        $_SESSION['player'] = $player;

}else {
        $game = $_SESSION['game'];
        $player = $_SESSION['player'];
        
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                                        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  <style type="text/css">
    html { height: 100% }
    body { height: 100%; margin: 0px; padding: 0px }
    #map_canvas { height: 100% ; width:100%;}
        #playerInfos{
        height: 50px;
        width:100%;
        position: absolute;
        left: 5px;
        bottom: 5px;
        color : white;
        font-size: 11px;
        background-image:url(images/barreInfo.png);
}

	.factionInfos {
		float: left;
		margin-right: 10px;
	
	}

        #loadTime{
        position: absolute;
        right: 751px;
        top: 249px;
        width: 304px;
}


        #shadowing
        {
          display: none;
          position: fixed;
          top: 0%;
          left: 0%;
          width: 100%;
          height: 100%;
          background-color: #CCA;
          z-index:10;
          opacity:0.5;
          filter: alpha(opacity=50);
        }


  </style>

        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
        <script type="text/javascript" src="http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/util.js"></script>
        <script type="text/javascript" src="js/geolocation.js"></script>
 
</head>

 
<body>

<div id="map_canvas">

</div>

<div id="playerInfos">

<?php 
$rebelsPowerBar = $game->rebelsFaction()->powerBar();
$oppressorsPowerBar = $game->oppressorsFaction()->powerBar();
?>

<TABLE>
	<TR>
		<TH></TH>
		<TH> Rebelles </TH>
		<TH> Oppresseurs </TH>
	</TR>
	<TR>
		<TH> Niveau </TH>
		<TD> <?php echo $rebelsPowerBar->level(); ?> </TD>
		<TD> <?php echo $oppressorsPowerBar->level(); ?> </TD>
	</TR>
	<TR>
		<TH> Pouvoir </TH>
		<TD> <?php echo $rebelsPowerBar->score(); ?> </TD>
		<TD> <?php echo $oppressorsPowerBar->score(); ?> </TD>
	</TR>
</TABLE> 

</div>

<script type="text/javascript">

initialize();


<?php 
$safeHavens = $game->safeHavens();

foreach ($safeHavens as $safeHaven) {
?>
	addSafeHaven(   '<?php echo $safeHaven->id(); ?>', 
                    '<?php echo $safeHaven->position()->latitude(); ?>',
                    '<?php echo $safeHaven->position()->longitude() ; ?>', 
                    '<?php echo $safeHaven->owner() ?>',
                    '<?php echo $safeHaven->playersIn()?>',
                    '<?php echo $player->faction()?>'
                 );     
<?
}

$rebels = $game->rebelsFaction()->factionMembers();

foreach ($rebels as $rebel) {
?>
	addRebel(   '<?php echo $rebel->emei(); ?>', 
                '<?php echo $rebel->position()->latitude(); ?>',
                '<?php echo $rebel->position()->longitude() ; ?>' 
            ); 
<?	
}

$oppressors = $game->oppressorsFaction()->factionMembers();

foreach ($oppressors as $oppressor) {
	?>
	addOppressor(   '<?php echo $oppressor->emei(); ?>', 
                '<?php echo $oppressor->position()->latitude(); ?>',
                '<?php echo $oppressor->position()->longitude() ; ?>' 
            ); 
<?	
}

?>
</script>

</body>
</html>